/**
 * 纸飞机
 */
cc.Class({
    extends: cc.Component,

    properties: {
        player: cc.Node
    },

    // onLoad () {},

    start() {
        this.playerRig = this.player.getComponent(cc.RigidBody);
        this.playerPhysicsBox = this.player.getComponent(cc.PhysicsBoxCollider);
    },

    onBeginContact: function (contact, selfCollider, otherCollider) {
        //纸飞机
        if (this.player.model === "Land" && otherCollider.tag === 88) {
            this.player.model = "Sky";
            this.player.prop = "uplift";
            this.playerRig._b2Body.m_gravityScale = 0.1;
            this.player.getComponent(cc.Animation).stop();
            this.player.getComponent(cc.Sprite).spriteFrame = cc.vv.res["Plane"];
            // this.playerPhysicsBox.offset.y = 0;
            // this.playerPhysicsBox.apply();
            // this.playerRig.fixedRotation = false;
            //this.playerRig._b2Body.m_linearVelocity.y = 0;

        } else if (this.player.model === "Sky" && otherCollider.tag === 88) {
            //陆地
            this.player.model = "Land";
            this.player.prop = "Jump";
            this.player.getComponent(cc.Sprite).spriteFrame = cc.vv.res["jump"];
            // this.playerPhysicsBox.offset.y = 27;
            // this.playerPhysicsBox.apply();
            this.playerRig._b2Body.m_linearVelocity.y = 0;
            this.playerRig._b2Body.m_linearVelocity.x = 5;
            this.playerRig._b2Body.m_gravityScale = 3;
            this.playerRig.fixedRotation = true;
            selfCollider.node.getComponent(cc.RigidBody).enabledContactListener = false;
        }
    },
});
